//
//  RShareViewController.m
//  iMoive
//
//  Created by 侯伟 on 2021/8/24.
//

#import "RShareViewController.h"
#import "RSVerButton.h"
#import "ShareHanler.h"
@interface RShareViewController ()

@end

@implementation RShareViewController

- (void)loadView{
    [super loadView];
    // 线性布局
    MyRelativeLayout *rootLayout = [MyRelativeLayout new];
    rootLayout.backgroundColor = COLOR_WHITE;
    self.view = rootLayout;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initSubViews];
}

- (void)initSubViews{
    UIImageView* bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"share_bg"]];
    bgImageView.myCenterX = 0;
    bgImageView.myCenterY = -75;
    [bgImageView sizeToFit];
    [self.view addSubview:bgImageView];
    
    
    UILabel* titleLb1 = [UILabel lableWithFont:FONTMID_FIT(20) color:COLOR_BLACK_DARK text:@"分享给朋友"];
    titleLb1.myHeight = MyLayoutSize.wrap;
    titleLb1.myCenterX = 0;
    titleLb1.topPos.equalTo(bgImageView.bottomPos).offset(28);
    [self.view addSubview:titleLb1];
    
    UILabel* titleLb2 = [UILabel lableWithFont:FONTMID_FIT(20) color:COLOR_BLACK_DARK text:@"一起来看最新影视资源"];
    titleLb2.myHeight = MyLayoutSize.wrap;
    titleLb2.myCenterX = 0;
    titleLb2.topPos.equalTo(titleLb1.bottomPos).offset(4);
    [self.view addSubview:titleLb2];
    
    MyLinearLayout *btnLayout = [MyLinearLayout linearLayoutWithOrientation:(MyOrientation_Horz)];
    btnLayout.myCenterX = 0;
    btnLayout.myHeight = MyLayoutSize.wrap;
    btnLayout.gravity = MyGravity_Horz_Between;
    btnLayout.subviewHSpace = 100.0;
    btnLayout.myBottom = 42;
    [self.view addSubview:btnLayout];
    
    RSVerButton* wxBtn = [RSVerButton buttonWithType:(UIButtonTypeCustom)];
    wxBtn.gap = 8;
    [wxBtn setImage:[UIImage imageNamed:@"share_wx"] forState:UIControlStateNormal];
    [wxBtn setTitle:@"微信" forState:UIControlStateNormal];
    [wxBtn setTitleColor:COLOR_BLACK_DARK forState:UIControlStateNormal];
    [wxBtn addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
    wxBtn.titleLabel.font = FONT_FIT(15);
    wxBtn.myMargin = 0;
    wxBtn.mySize = CGSizeMake(PX(80), PX(80));
    [btnLayout addSubview:wxBtn];
    
    RSVerButton* copyBtn = [RSVerButton buttonWithType:(UIButtonTypeCustom)];
    copyBtn.gap = 8;
    [copyBtn setImage:[UIImage imageNamed:@"share_copy"] forState:UIControlStateNormal];
    [copyBtn setTitle:@"复制连接" forState:UIControlStateNormal];
    [copyBtn setTitleColor:COLOR_BLACK_DARK forState:UIControlStateNormal];
    [copyBtn addTarget:self action:@selector(copyUrl:) forControlEvents:UIControlEventTouchUpInside];
    copyBtn.titleLabel.font = FONT_FIT(15);
    copyBtn.myMargin = 0;
    copyBtn.mySize = CGSizeMake(PX(80), PX(80));
    [btnLayout addSubview:copyBtn];
}

- (void)share:(UIButton*)sender{
    [ShareHanler shareAPP];
}

- (void)copyUrl:(UIButton*)sender{
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    [pasteboard setString:APP_STORE_URL];
    [Toast toast:@"复制成功"];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
